package com.itlong.cloud.commons;

import com.itlong.cloud.equip.commons.ICloudElevatorServiceClient;
import com.itlong.cloud.equip.commons.IPushCloudElevatorChangeLogServiceClient;
import com.itlong.cloud.utils.date.DateUtil;
import org.slf4j.Logger;import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.web.bind.annotation.RestController;

import java.util.Calendar;

/**
 * <desc>
 *      云电梯响应硬件结果任务调度类
 * </desc>
 *
 * @createDate 2018/04/03
 */
@EnableScheduling // 启用定时任务
@RestController
public class PushCloudElevatorChangeLogTimeTask {
    private static Logger LOG = LoggerFactory.getLogger(PushCloudElevatorChangeLogTimeTask.class);

    @Autowired
    IPushCloudElevatorChangeLogServiceClient iPushCloudElevatorChangeLogServiceClient;

    /**
     * <desc>
     *      同步业务指令至响应硬件结果表
     * </desc>
     *
     * @author Juguang.S
     * @creatDate 2018/04/03
     */
//    @Scheduled(cron = "0/30 * * * * ?") // 每30秒执行一次
    public void timeTaskSychro() {
        try {
            iPushCloudElevatorChangeLogServiceClient.timeTaskPushCloudElevator();
//            LOG.info("【定时任务】同步业务指令至响应硬件结果表执行成功，当前时间：" + DateUtil.format(Calendar.getInstance(), "yyyy-MM-dd HH:mm:ss"));
        }catch (Exception e){
            LOG.error("【定时任务】同步业务指令至响应硬件结果表执行失败，当前时间：" + DateUtil.format(Calendar.getInstance(), "yyyy-MM-dd HH:mm:ss:"),e);
        }
    }
}
